/*
 * @Description: vue.config 配置
 * @Author: oscar
 * @Date: 2021-12-09 21:53:26
 */
const tsImportPluginFactory = require("ts-import-plugin");
const { merge } = require("webpack-merge");

module.exports = {
  chainWebpack(config) {
    // 配置VantUI按需引入
    config.module
      .rule("ts")
      .use("ts-loader")
      .tap((options) => {
        options = merge(options, {
          transpileOnly: true,
          getCustomTransformers: () => ({
            before: [
              tsImportPluginFactory({
                libraryName: "vant",
                libraryDirectory: "es",
                style: true,
              }),
            ],
          }),
          compilerOptions: {
            module: "es2015",
          },
        });
        return options;
      });
  },
  // 反向代理
  devServer: {
    proxy: {
      "/reqapi": {
        target: "http://localhost:8000",
        // target: 'http://api.work.fissiongeek.com/workwechat',
        changeOrigin: true,
        pathRewrite: {
          "^/reqapi": "",
        },
      },
    },
  },
};
